/** 重置样式 */
import '@/styles/reset.css'
import 'uno.css'
import '@/styles/global.scss'
import 'virtual:svg-icons-register'

import { createApp } from 'vue'
import { setupRouter } from '@/router'
import { setupStore } from '@/store'
import App from './App.vue'
import { setupNaiveDiscreteApi } from './utils'
import { NODE_SIZE } from '@/constant'
import { Graph } from '@antv/x6'
import { Boot } from '@wangeditor/editor'
import attachmentModule from '@wangeditor/plugin-upload-attachment'


// 监听localStorage引入
import {dispatchEventStrage} from "@/utils/watchLocalStorage";
// 富文本编辑器注册模块 (只能注册一次，不可重复注册。)
Boot.registerModule(attachmentModule)

async function setupApp() {
  const app = createApp(App)

  setupStore(app)
  setupNaiveDiscreteApi()

  await setupRouter(app)
    app.use(dispatchEventStrage)
  app.mount('#app')
}

setupApp()

Graph.registerNode(
  'flow-node',
  {
    inherit: 'rect',
    height: NODE_SIZE.NODE_HEIGHT,
    width: NODE_SIZE.NODE_WIDTH,
    markup: [
      {
        tagName: 'rect',
        selector: 'body',
      },
      {
        tagName: 'text',
        selector: 'label',
      },
    ],
    attrs: {
      body: {
        stroke: '#1a365d',
        strokeWidth: 1,
        rx: 8,
        ry: 8,
      },
      label: {
        fill: '#333',
      },
    },
    ports: {
      groups: {
        left: {
          position: 'left',
          attrs: {
            circle: {
              r: 0,
            },
          },
        },
        right: {
          position: 'right',
          attrs: {
            circle: {
              r: 0,
            },
          },
        },
        top: {
          position: 'top',
          attrs: {
            circle: {
              r: 0,
            },
          },
        },
        bottom: {
          position: 'bottom',
          attrs: {
            circle: {
              r: 0,
            },
          },
        },
      },
    },
  },
  true
)
